import { MountEquipToolTipInfo } from "../../../resource/info/MountEquipToolTipInfo";
import { Language } from "../../../../../extend/language/Language";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { MountUtil } from "../../../scene/mount/MountUtil";
import { GameDefConfig } from "../../../resource/GameDefConfig";
import { ObjCreate } from "../ObjCreate";
import { GTextFormat } from "../../../../common/GTextFormat";
import { FontUtil } from "../../../../common/font/FontUtil";
import { ImagesConst } from "../../../resource/ImagesConst";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { BaseItem } from "../BaseItem";
import { EquipmentItemDataUtil } from "../EquipmentItemDataUtil";
import { TItemWeapon } from "../../../../../Message/Db/Tables/TItemWeapon";
import { EBind } from "../../../../../Message/Public/EBind";
import { ColorConfig } from "../../../resource/ColorConfig";
import { ParamsConst } from "../../../../common/global/ParamsConst";
import { ProxyType } from "../../../../common/global/ProxyType";
import { ItemData } from "../../../resource/info/ItemData";
import { ItemInfo } from "../../../resource/info/ItemInfo";
import { ItemExInfo } from "../../../resource/info/ItemExInfo";
type int = number;
//class MountEquipTooltip
    
    export  class MountEquipTooltip /* flash.display.Sprite */
    {
        constructor(arg1: MountEquipToolTipInfo)
        {
            
            this.initUI();
            this.data = arg1;
            return;
        }

        /* internal  */getNeedLevelStr(): string
        {
            var loc1=Language.getString(74212);
            var loc2="#00ff00";
            return HTMLUtil.addColor(loc1, loc2);
        }

        /* internal  */getEqType(): string
        {
            var loc1="";
            if (this._tItemWeap) 
            {
                loc1 = MountUtil.instance.getMountEquipName(this._tItemWeap.type);
            }
            return HTMLUtil.addColor(loc1, "#FFFFFF");
        }

        public getBasicProps(): string
        {
            var loc4=null;
            var loc5=null;
            var loc6=0;
            var loc7=null;
            var loc8=0;
            var loc9=null;
            if (!this._eqDataUtil && !this._itemData) 
            {
                return "";
            }
            var loc1="";
            var loc2=this._eqDataUtil.getBasePropArray();
            if (loc2.length > 0) 
            {
                loc1 = HTMLUtil.addColor(Language.getString(51092), "#fe7d00");
            }
            var loc3=0;
            while (loc3 < loc2.length) 
            {
                loc5 = (loc4 = loc2[loc3] as Map<any, any> /* flash.utils.Dictionary */)["name"];
                loc6 = loc4["value"];
                loc7 = "";
                loc8 = loc4["type"];
                if (this._itemExInfo) 
                {
                    if ((loc9 = MountUtil.instance.getMountEquipAddAttDict(this._itemData.type, this._itemData.color, this._itemData.itemExInfo.m_equip_star))[loc8.toString()]) 
                    {
                        loc7 = "  +  " + loc9[loc8.toString()];
                    }
                    else 
                    {
                        loc7 = "  +  0";
                    }
                }
                if (loc5.length != 2) 
                {
                    loc1 = loc1 + ("\r    " + loc5 + "    " + loc6 + loc7);
                }
                else 
                {
                    loc1 = loc1 + ("\r    " + loc5 + "        " + loc6 + loc7);
                }
                ++loc3;
            }
            if (loc1 != "") 
            {
                loc1 = "<textFormat leading=\'7\'>" + HTMLUtil.addColor(loc1, "#ffffff") + "</textFormat>";
            }
            return loc1;
        }

        public getEqDescText(): string
        {
            var loc1="";
            if (this._tItemWeap) 
            {
                if (!(this._tItemWeap.descStr == "") && !(this._tItemWeap.descStr == "0")) 
                {
                    loc1 = "<textFormat leading=\'5\'>" + HTMLUtil.addColor(Language.getString(51102) + this._tItemWeap.descStr, "#ffffff") + "</textFormat>";
                }
            }
            return loc1;
        }

        public getSellToSysText(): string
        {
            var loc3=null;
            var loc1="";
            var loc2="";
            if (this._tItemWeap) 
            {
                if (this._tItemWeap.sell == 1) 
                {
                    loc3 = GameDefConfig.instance.getEPrictUnitName(this._tItemWeap.sellUnit);
                    loc2 = this._tItemWeap.sellPrice + "\t" + loc3;
                }
            }
            if (loc2 != "") 
            {
                loc1 = Language.getString(51104) + loc2;
            }
            return loc1;
        }

        /* internal  */getTipsText(): string
        {
            var loc1="";
            var loc2="";
            var loc3=this._itemExInfo ? this._itemExInfo.p_equip_star : 0;
            var loc4=this._itemData ? this._itemData.color : 0;
            loc2 = Language.getString(61338);
            if (loc2 != "") 
            {
                loc1 = Language.getString(51110) + loc2;
            }
            return loc1;
        }

        /* internal  */getBind(): int
        {
            var loc1=0;
            if (this._tItemWeap) 
            {
                loc1 = this._tItemWeap.bind;
                if (this._itemExInfo && !(this._itemExInfo.bind == 0)) 
                {
                    loc1 = this._itemExInfo.bind;
                }
            }
            return loc1;
        }

        /* internal  */initUI(): void
        {
            this._nameTxt = ObjCreate.createTextField("", 45 + this._leftX, 0, 113, 20, this, new GTextFormat(FontUtil.songtiName, 14, null, true));
            this._nameTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._starLvTx = ObjCreate.createTextField("", 150, 0, 25, 20, this, new GTextFormat(FontUtil.songtiName, 14, null, true));
            this._starLvTx.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._starBm = ObjCreate.createBitmap(ImagesConst.littleStar_light, 175, 1, this);
            this._lockBitmap = new Object /* flash.display.Bitmap */();
            this._lockBitmap.x = this._leftX;
            this.addChild(this._lockBitmap);
            this._bindTxt = ObjCreate.createTextField("", 25, 0, 80, 20, this, new GTextFormat(FontUtil.songtiName, 12, 65280));
            this._bindTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._needLevelTxt = ObjCreate.createTextField("", 70, 17, 100, 20, this, new GTextFormat(FontUtil.songtiName, 12, 16777215));
            this._needLevelTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._imageBg = GlobalClass.getBitmap(ImagesConst.PackItemBg);
            this.addChild(this._imageBg);
            this._eqItem = new BaseItem();
            this._eqItem.setSize(32, 32);
            this._eqItem.isShowToolTip = false;
            this._eqItem.isDragAble = false;
            this.addChild(this._eqItem);
            this._eqTypeTxt = ObjCreate.createTextField("", 70, 12, 100, 20, this, new GTextFormat(FontUtil.songtiName, 12, 16777215));
            this._eqTypeTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._basicPropTxt = ObjCreate.createTextField("", this._leftX, 0, 100, 20, this, new GTextFormat(FontUtil.songtiName, 12, 16777215));
            this._basicPropTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._baseLine = ObjCreate.createBg(0, 0, this._lineWidth, 1, this, ImagesConst.SeptalLine);
            this._eqDescTxt = ObjCreate.createTextField("", this._leftX, this._currentY, 185, 20, this, new GTextFormat(FontUtil.songtiName, 12, 16777215));
            this._eqDescTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._eqDescTxt.wordWrap = true;
            this._eqDescTxt.multiline = true;
            this._repairTxt = ObjCreate.createTextField("", this._leftX, this._currentY, 200, 20, this, new GTextFormat(FontUtil.songtiName, 12, 16777215));
            this._repairTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._sellToSysTxt = ObjCreate.createTextField("", this._leftX, this._currentY, 200, 20, this, new GTextFormat(FontUtil.songtiName, 12, 15319853));
            this._sellToSysTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._sendToChatTxt = ObjCreate.createTextField("", this._leftX, this._currentY, 200, 20, this, new GTextFormat(FontUtil.songtiName, 12, 16777215));
            this._sendToChatTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._sendToChatTxt.text = Language.getString(51086);
            this._tipTxt = ObjCreate.createTextField("", this._leftX, this._currentY, 200, 20, this, new GTextFormat(FontUtil.songtiName, 12, 51429));
            this._tipTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            return;
        }

        public set data(arg1: MountEquipToolTipInfo)
        {
            this._data = arg1;
            this._itemData = arg1.itemdata;
            this._itemInfo = this._itemData ? this._itemData.itemInfo : null;
            this._itemExInfo = this._itemData ? this._itemData.itemExInfo : null;
            this._eqDataUtil = this._itemData ? new EquipmentItemDataUtil(this._itemData) : null;
            if (this._itemInfo && this._itemInfo.extend && this._itemInfo.extend is TItemWeapon) 
            {
                this._tItemWeap = this._itemInfo.extend as TItemWeapon;
            }
            this.updateUI();
            return;
        }

        /* internal  */updateUI(): void
        {
            this._currentY = 0;
            this._nameTxt.htmlText = this.getNameText();
            this._starLvTx.htmlText = this.getStrengName();
            this._currentY = this._currentY + this._nameTxt.height;
            var loc1=this.getBind();
            if (loc1 != EBind._EBindYes) 
            {
                this._lockBitmap.bitmapData = null;
                this._bindTxt.x = 7;
            }
            else 
            {
                this._lockBitmap.bitmapData = GlobalClass.getBitmapData(ImagesConst.EqBind);
                this._lockBitmap.y = this._currentY + 2;
                this._bindTxt.x = 25;
            }
            this._bindTxt.text = GameDefConfig.instance.getEBind(loc1).name;
            this._bindTxt.y = this._currentY;
            this._currentY = this._currentY + this._bindTxt.height;
            this._imageBg.x = this._leftX + 5;
            this._imageBg.y = this._currentY + 8;
            this._eqItem.itemData = this._itemData;
            this._eqItem.x = this._imageBg.x + 3;
            this._eqItem.y = this._imageBg.y + 3;
            this._needLevelTxt.htmlText = this.getNeedLevelStr();
            this._needLevelTxt.y = this._currentY;
            this._currentY = this._currentY + (this._needLevelTxt.height + 5);
            this._eqTypeTxt.htmlText = this.getEqType();
            this._eqTypeTxt.y = this._currentY;
            this._currentY = this._currentY + (this._eqTypeTxt.height + 14);
            this._basicPropTxt.htmlText = this.getBasicProps();
            this._basicPropTxt.y = this._currentY;
            this._currentY = this._currentY + (this._basicPropTxt.height + 3);
            this._baseLine.y = this._currentY;
            this._currentY = this._currentY + (this._baseLine.height + 2);
            var loc2=this.getEqDescText();
            this._eqDescTxt.htmlText = loc2;
            this._eqDescTxt.y = this._currentY;
            this._currentY = this._currentY + this._eqDescTxt.height;
            var loc3=this.getSellToSysText();
            this._sellToSysTxt.htmlText = loc3;
            this._sellToSysTxt.y = this._currentY;
            this._currentY = this._currentY + this._sellToSysTxt.height;
            this._sendToChatTxt.y = this._currentY;
            this._currentY = this._currentY + this._sendToChatTxt.height;
            var loc4=this.getTipsText();
            this._tipTxt.htmlText = loc4;
            this._tipTxt.y = this._currentY;
            this._currentY = this._currentY + this._tipTxt.height;
            return;
        }

        public getNameText(): string
        {
            var loc3=null;
            var loc1="";
            var loc2="#FFFF00";
            if (this._tItemWeap) 
            {
                loc1 = this._tItemWeap.name;
                loc2 = ColorConfig.instance.getItemColorString(this._tItemWeap.color);
            }
            if (ParamsConst.instance.proxyType == ProxyType.TW && !(ParamsConst.instance.gameName == null)) 
            {
                if (loc1.indexOf(ParamsConst.instance.gameName) >= 0) 
                {
                    loc3 = new RegExp(ParamsConst.instance.gameName, "g");
                    loc1 = loc1.replace(loc3, "");
                }
            }
            return HTMLUtil.addColor(loc1, loc2);
        }

        /* internal  */getStrengName(): string
        {
            var loc2=null;
            var loc1="";
            if (this._tItemWeap && this._itemExInfo) 
            {
                loc2 = ColorConfig.instance.getItemColorString(this._tItemWeap.color);
                loc1 = HTMLUtil.addColor(this._itemExInfo.m_equip_star.toString(), loc2);
            }
            return loc1;
        }

        /* internal */ /* var */_lineWidth: int=210;

        /* internal */ /* var */_leftX: int=10;

        /* internal */ /* var */_currentY: int=10;

        /* internal */ /* var */_nameTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_starLvTx: Object /* flash.text.TextField */;

        /* internal */ /* var */_starBm: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_lockBitmap: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_bindTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_needLevelTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_imageBg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_eqItem: BaseItem;

        /* internal */ /* var */_eqTypeTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_basicPropTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_baseLine: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_eqDescTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_repairTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_sellToSysTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_sendToChatTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_eqDataUtil: EquipmentItemDataUtil;

        /* internal */ /* var */_data: MountEquipToolTipInfo;

        /* internal */ /* var */_itemData: ItemData;

        /* internal */ /* var */_itemInfo: ItemInfo;

        /* internal */ /* var */_itemExInfo: ItemExInfo;

        /* internal */ /* var */_tItemWeap: TItemWeapon;

        /* internal */ /* var */_tipTxt: Object /* flash.text.TextField */;
    }
